<?php

if ( empty($paramsArr['id']) )
	showMsg('Mã lỗi: 0x0001 ==> Không có dữ liệu !','ex','center');
else
{
	$sql = "SELECT * FROM pctroubleshooting_article WHERE Id=".$paramsArr['id']." AND tmp=0";
	$rs = $link->Execute($sql);
	
	if ( $rs->EOF )
		showMsg('Mã lỗi: 0x0002 ==> Không có dữ liệu !','ex','center');
	else
	{
		$template->set_filenames(array(
			'body'=>'view_detail_item.tpl'
		));
		$template->assign_vars(array(
			'_QUESTIONER'=>$rs->fields('questioner'),
			'_QUESTIONDATE'=>toVNDate($rs->fields('question_date')),
			'_QUESTIONEMAIL'=>$rs->fields('email_questioner'),
			'_QUESTION'=>$rs->fields('question_' . $_SESSION['cur_lang']),
			'_ANSWERER'=>$rs->fields('answerer'),
			'_ANSWERDATE'=>toVNDate($rs->fields('answer_date')),
			'_ANSWEREMAIL'=>$rs->fields('email_answerer'),
			'_ANSWER'=>$rs->fields('answer_' . $_SESSION['cur_lang']),
			'_LB_QUESTION'=>$lang['l_pc_question'],
			'_LB_QUESTIONER'=>$lang['l_pc_questioner'],
			'_LB_ANSWER'=>$lang['l_pc_answer'],
			'_LB_ANSWERER'=>$lang['l_pc_answerer'],
			'_LB_MOREQUESTION'=>$lang['l_pc_morequestion']
		));
		
		/* Lấy các câu hỏi khác cùng hủ đề */
		$sql = "SELECT * FROM pctroubleshooting_article WHERE Id NOT IN(" . $paramsArr['id'] . ") AND tmp=0 AND tid=" . $rs->fields('tid') . " ORDER BY question_date desc, answer_date desc";
		$rs = $link->Execute($sql);
		
		while ( !$rs->EOF )
		{
			$template->assign_block_vars('more',array(
				'_QUESTION'=>$rs->fields('question_' . $_SESSION['cur_lang']),
				'_DATE'=>toVNDate($rs->fields('question_date')),
				'_QUESTIONER'=>$rs->fields('questioner'),
				'_MOREQUESTION_LINK'=>setURLParams('act=dyn&mod=PCTroubleshooting&f=view_detail_item&id='.$rs->fields('Id'))
			));
			
			$rs->MoveNext();
		}		
		
		$template->pparse('body');
	}
}

?>